package com.example.mobile2032021606168xmy0330;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import javax.xml.namespace.QName;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private EditText edtTextMainName;
    private EditText edtTextMainPsw;
    private Button btnMainLogin;
    private Button btnMainPsw;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String account = edtTextMainName.getText().toString();
                String password = edtTextMainPsw.getText().toString();

                if (account.length() == 0) {
                    Log.i("登录", "请输入用户名");
                } else if (password.length() == 0) {
                    Log.i("登录", "请输入密码");
                } else {
                    if (account.equals("admint") & password.equals("123456")) {
                        Log.i("登录", "登录成功");
                    } else {
                        Log.i("登录", "登陆失败");
                    }
                    edtTextMainName.setText(null);
                    edtTextMainPsw.setText(null);
                }
            }
        });


                btnMainLogin.setOnClickListener(new View.OnClickListener()

            {
                @Override
                public void onClick (View v){
                edtTextMainName.setText(null);
                edtTextMainPsw.setText(null);
               }
             });



        }


            private void initView() {
                tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
                edtTextMainName = (EditText) findViewById(R.id.edtText_main_name);
                edtTextMainPsw = (EditText) findViewById(R.id.edtText_main_psw);
                btnMainLogin = (Button) findViewById(R.id.btn_main_login);
                btnMainPsw = (Button) findViewById(R.id.btn_main_psw);
            }



        }

